$(document).ready(function () {
	$('.add-btn').click(function () {
		$('#joinModal').show()
	});
	const prov = $('.select-all #prov');
	const city = $('.select-all #city');
	const country = $('.select-all #country');
	let current = {
		prov: '',
		city: '',
		country: ''
	}
	$.ajax({
		url: 'http://tmtx.test.dgyunju.cn/api/area',
		type: 'get',
		data: { lang: 'zh-cn' },
		dataType: 'json',
		success: function (res) {
			console.log(1);
			const list = res.data
			list.forEach((i, v) => {
				let provOpt = document.createElement('option');
				provOpt.innerText = i.name;
				provOpt.value = i.name
				prov.append(provOpt);
			})
			prov.on("change", function () {
				$('.select-all #city option').remove()
				let textA = prov.val()
				list.forEach(i => {
					if (i.name === textA) {
						i.children.forEach(i2 => {
							let provOpt = document.createElement('option');
							provOpt.innerText = i2.name;
							provOpt.value = i2.name
							city.append(provOpt)
						})
					}
				})
			});
		},
	})

	// 显示弹窗
	$('#privacyLink').click(function () {
		$('#privacyModal').show();
	});

	// 点击遮罩层关闭弹窗
	$('#privacyModal').click(function (e) {
		if ($(e.target).hasClass('modal-mask')) {
			$('#privacyModal').hide();
		}
	});

});